<?php 



	//simple methods for bitly.. don't need a class.. simple functions only..
	
	
	function fta_bitlyShorten($url){
		//assume that we have bitly api keys and what not.. 
		global $FTABitlyLogin;
		global $FTABitlyAPIKey;
		
		$url = urlencode($url);
		
		$url = 'http://api.bit.ly/v3/shorten?login=' . $FTABitlyLogin .'&apiKey=' . $FTABitlyAPIKey. '&uri=' . $url . '&format=json';	

		
		$json = file_get_contents($url);
		
		$o = json_decode($json);

		if (is_null($o))
			return null;

		if ("OK"  == $o->status_txt) {
			return $o->data->url;
		}
		
		return null;
		
	}
	
	function fta_bitlyShortenOrSelf($url){
		$u = fta_bitlyShorten($url);
		
		//possible log here.. hrrm.. 
		
		return (is_null($u) ? $url : $u);
	}